#include <iostream>
#include <stack>

using namespace std;

//两个栈实现一个队列

class stackQueue
{
    stack<int> m_s1;
    stack<int> m_s2;
    public:
    stackQueue()
    {

    }

    void push(int i)
    {
        m_s1.push(i);
    }

    void pop()
    {
        while (m_s1.size() > 1)//在第一个栈中循环取栈顶压入第二个栈中并删除, 直至第一个栈中只剩下一个数据
        {
            m_s2.push(m_s1.top());
            m_s1.pop();
        }
        m_s1.pop(); //第一个栈中只剩下最后一个数据pop出

        while (!m_s2.empty())
        {
            m_s1.push(m_s2.top());
            m_s2.pop();
        }
    }

    int front()
    {
        while (m_s1.size() > 1)
        {
            m_s2.push(m_s1.top());
            m_s1.pop();
        }
        int tmp = m_s1.top();

        while (!m_s2.empty())
        {
            m_s1.push(m_s2.top());
            m_s2.pop();
        }
        return tmp;
    }

   // int back()
    //{
     //   return m_s1.top();
    //}

};

int main()
{
    stackQueue sq;
    sq.push(2);
    sq.push(3);
    sq.push(4);

    cout << sq.front() << endl;
    sq.pop();
    cout << sq.front() << endl;
    sq.pop();
    cout << sq.front() << endl;

    return 0;
}
